package org.example.循环;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author mumucgq
 * @create 2020-12-22 16:06
 */
public class ForRemoveIterTest {
    public static void main(String[] args) {
        ArrayList<String> userNames = new ArrayList<String>() {{
            add("Hollis");
            add("hollis");
            add("HollisChuang");
            add("H");
        }};

        userNames.remove("H");
        Iterator iterator = userNames.iterator();

        while (iterator.hasNext()) {
            if (iterator.next().equals("Hollis")) {
                iterator.remove();
            }
        }
        System.out.println(userNames);

    }
}
